package pl.edu.mimuw.irs.core.model.design;

import java.util.List;
import java.util.Set;

import pl.edu.mimuw.irs.core.model.analysis.subnet.AtomicSubnet;
import pl.edu.mimuw.irs.core.model.design.Fragmentation.Type;
import pl.edu.mimuw.irs.core.model.petrinet.INode;

/**
 * @author Jakub Rauch
 * Created on: 2009-05-09
 */
public interface IRSNodeInterface extends INode {

	// *** Attributes

	// Getters and setters
	public NodeType getNodeType();
	public void setNodeType(NodeType nodeType);
	public Fragmentation getFragmentation();
	public void setFragmentation(Fragmentation fragmentation);
	public IRSNodeInterface getParent();
	public void setParent(IRSNodeInterface parent);
	public List<IRSNodeInterface> getChildren();
	/**
	 * This method assumes, that children are in proper structure for the fragmentation.
	 * Because of that this function should be used only for setting copied parameters from
	 * other nodes of the same type.
	 * @param children
	 * @param fragmentation
	 */
	public void setChildren(List<IRSNodeInterface> children, Fragmentation fragmentation);
	public void addChild(IRSNodeInterface node);
	public void addChild(int i, IRSNodeInterface node);
	public void removeChild(IRSNodeInterface node);
	public List<IRSNodeInterface> getInputChildren();
	public List<IRSNodeInterface> getOutputChildren();
	public boolean isAtomic();
	AtomicSubnet getAtomicWorkflow(AtomicSubnet subnet);
	public List<IRSArc> getAtomicIncomingArcs();
	public List<IRSArc> getAtomicOutgoingArcs();
	
	// Useful for graphical tool
	public Set<Type> getSupportedFragmentations();
	public boolean isExpanded();
	public void setExpanded(boolean expand);
	
	// *** Methods
	
	/**
	 * Checks if this node is a root - has no parents.
	 */
	public boolean isRoot();

	/**
	 * Returns all leaf nodes from this one.
	 * TODO : remove
	 */
	public List<IRSNodeInterface> getAtomicNodes();
	
	/**
	 * Returns non expanded descendants of expanded nodes or self.
	 * TODO : remove
	 */
	public List<IRSNodeInterface> getExpandedNodes();
	

	/**
	 * Creates copy of this node - copies children and creates arcs between them. All
	 * arcs that accessesing nodes not being inside of this node will not be copied.
	 * @return copied node
	 */
	public IRSNodeInterface copy();
	
	public void destroy();
	
	// *** Enums
	
	/**
	 * Type of node (activity, normal transition,...) - used to distinguish nodes
	 * in IRSWorkflow. Distinguished nodes can be efficiently managed. 
	 */
	public enum NodeType {
		TRANSITION,
		ACTIVITY,
		PLACE,
		RESOURCE;
	}

}
